package tests;
import static org.junit.Assert.*;
import model.Prescription;
import model.PrescriptionBox;
import model.PrescriptionObject;
import org.junit.Before;
import org.junit.Test;
import view.Designer;
/** * A testing class for the prescription 
 * @author Daniel Bond
 */
public class PrescriptionTest {
	private Designer designer = Designer.getInstance();
	private Prescription prescription = Prescription.getInstance();	
	/**
	 * @throws Exception
	 */
	@Before
	public void setUp() throws Exception {
	}
	/**
	 * Testing that an inserted object has the correct selected object index
	 */
	@Test
	public void objectTest(){
		PrescriptionObject box = new PrescriptionBox();
		prescription.addObject(box);
		prescription.setSelected(prescription.objects().size()-1);
		designer.update();
		assertEquals(0, prescription.getSelectedIndex()); //if only one box is added, the index should be 0
	}
	/**
	 * Testing that the height of a prescription is set correctly
	 */
	@Test
	public void prescriptionHeightTest(){
		prescription.changePrescriptionHeight("400");
		assertEquals(400, prescription.getHeight());
	}
	/**
	 * Testing that the width of a prescription is set correctly.
	 */
	@Test
	public void prescriptionWidthTest(){
		prescription.changePrescriptionWidth("350");
		assertEquals(350, prescription.getWidth());
	}
	/**
	 * Testing that the serial number is displayed on the prescription correctly.
	 */
	@Test
	public void prescriptionSerialNumberTest(){
		prescription.setSerialNumber("test");
		assertEquals("test", prescription.getSerialNo());
	}
}